<template>
  <!-- 我的收藏 -->
  <div class="colLect">
    <el-card class="box-card">
      <ul class="top-ul">
        <el-table :data="recordsLists" border style="width: 100%">
          <el-table-column fixed prop="hotName" label="热点名称" width="150">
          </el-table-column>
          <el-table-column prop="collectionStatus" label="是否收藏" width="120">
          </el-table-column>
          <el-table-column prop="createTime" label="创建时间：" width="250">
          </el-table-column>
          <el-table-column prop="right" label="操作" width="100">
            <template slot-scope="scope">
              <el-button type="primary" @click="remchange(scope.row)"
                >删除</el-button
              >
            </template>
          </el-table-column>
        </el-table>
      </ul>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      recordsList: [],
    };
  },
  computed: {
    recordsLists() {
      return this.recordsList.map((item) => {
        if (item.collectionStatus == 1) {
          item.collectionStatus = "收藏";
        } else {
          item.collectionStatus = "未收藏";
        }
        return item;
      });
    },
  },
  methods: {
    // 是否收藏
    async ydcp_conllection() {
      const userId = localStorage.getItem("USERID");
      let result = await this.$request.requserHotcol(userId);
      this.recordsList = result.data
    },
    async remchange(e) {
      let params = {
        collectionStatus: 0,
        userId: localStorage.getItem("USERID"),
        hotId: e.hotId,
      };
      let resuklt = await this.$request.col(params);

      if (resuklt.code == 200) {
        this.$notify({
          title: "成功",
          message: "删除成功",
          type: "success",
        });
        this.ydcp_conllection();
      } else {
        this.$notify.error({
          title: "错误",
          message: "删除失败",
        });
      }
    },
  },
  mounted() {
    this.ydcp_conllection();
  },
};
</script>

<style lang="less">
::v-deep .el-table {
  text-align: center;
}
</style>
